<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/5
 * Time: 9:07
 */
namespace app\index\model;
use think\Db;

class BalanceLog extends BaseModel
{
    protected $table = 'bl_balance_log';
    protected $rule = [
        'uid'  =>  '',
    ];
    protected $msg = [
        'uid'  =>  '',
    ];
    protected $return = array();
  //  $uid  用户ID  $type  资金类型 $from_type   变更类型
    public function getLogList($uid,$type="",$from_type=false)
    {
        $page=input("post.page");
          $where=array(
              "user_id"=>$uid,
              "balance_type"=>$type,
          );
        if($from_type!==false)
        {
            $where["from_type"]=$from_type;
        }
        return $this->where($where)->page($page,10)->order("id desc")->select();
    }
    public function getLogListU($uid,$type="",$from_type=false)
    {
        $page=input("post.page");
        $where=array(
            "bl.user_id"=>$uid,
            "bl.balance_type"=>$type,
        );
        if($from_type!==false)
        {
            $where["bl.from_type"]=$from_type;
        }
        return $this->alias("bl")
            ->join("__USERS__ u","bl.to_user_id=u.user_id","left")
            ->join("__INVEST__ i","i.id=u.level","left")
            ->where($where)
            ->field("bl.*,u.user_name,i.name,i.name_en")->order("bl.id desc")
            ->page($page,10)->select();
    }


}
?>
